package com.jy.novel.controller;

import com.jy.novel.common.CommonResult;
import com.jy.novel.controller.base.BaseController;
import com.jy.novel.service.NovelCategoryService;
import org.apache.commons.lang.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by jihb on 4/30/16.
 */
@Controller
@RequestMapping("/novelcategory")
public class NovelCategoryController extends BaseController {

    @Autowired
    NovelCategoryService categoryService;

    @RequestMapping(value = "/manager",method = RequestMethod.GET)
    public String categoryManager(){
        return "novel/novelcategory_manager";
    }

    @RequestMapping(value = "/tree",method = RequestMethod.GET)
    @ResponseBody
    public Object categoryTree(
            @RequestParam(value = "parentId",defaultValue = "0")String parentId
    ){
        CommonResult result = categoryService.findNovelCategoryList(NumberUtils.toLong(parentId));
        return result.getResult();
    }
}
